//
//  SupplyAndDemandDetailsView.m
//  phmall
//
//  Created by admin on 2017/12/20.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "SupplyAndDemandDetailsView.h"

@implementation SupplyAndDemandDetailsView

-(instancetype)init{
    if (self=[super init]) {
        self.backgroundColor =[UIColor whiteColor];
        self.head=[[UIImageView alloc]init];
        [self addSubview:self.head];
        self.head.contentMode=UIViewContentModeScaleAspectFill;
//        self.head.image=[UIImage imageNamed:@"图片"];
        self.head.layer.cornerRadius = 5;
        
        self.name=[[UILabel alloc] init];
//        self.name.text=@"玛丽苏";
        self.name.font=[UIFont systemFontOfSize:15];
        [self addSubview:self.name];
        
        self.type=[[UILabel alloc] init];
//        self.type.text=@"正在进行中";
        self.type.textColor=[UIColor orangeColor];
        self.type.font=[UIFont systemFontOfSize:13];
        [self addSubview:self.type];
        
        self.time=[[UILabel alloc] init];
        [self addSubview:self.time];
        self.time.font=[UIFont systemFontOfSize:13];
        self.time.textColor=[UIColor colorWithHexString:@"#c5c5c5"];
//        self.time.text=@"发布时间:2017-08-17";
        
        //轮播图
        self.goods_pic = [[UIImageView alloc] init];
        self.goods_pic.contentMode=UIViewContentModeScaleAspectFill;
        [self addSubview:_goods_pic];
        
        self.title=[[UILabel alloc] init];
        self.title.textColor=[UIColor blackColor];
        self.title.numberOfLines=2;
        self.title.font=[UIFont systemFontOfSize:15];
        [self addSubview:self.title];

        self.price=[[UILabel alloc] init];
        [self addSubview:self.price];
        self.price.font=[UIFont systemFontOfSize:15];
        self.price.textColor=[UIColor orangeColor];
        self.price.text=@"₱";
        
        self.number=[[UILabel alloc] init];
        self.number.text=@"剩:     件";
        self.number.textColor=[UIColor orangeColor];
        self.number.font=[UIFont systemFontOfSize:13];
        [self addSubview:self.number];
        
    
        self.intro =[[UILabel alloc] init];
        self.intro.numberOfLines=0;
//        self.intro.text=@"晒单理由:晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由晒单理由";
        self.intro.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.intro.font=[UIFont systemFontOfSize:15];
        [self addSubview:self.intro];

    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.head mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.offset(10);
        make.width.height.offset(50);
    }];
    ;
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.head.mas_right).offset(5);
        make.top.equalTo(self.head).offset(5);
    }];
    
    [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.name);
        make.bottom.equalTo(self.head).offset(-5);
    }];
    
    [self.type mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.centerY.equalTo(self.head).offset(0);
    }];
    
    [self.goods_pic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.head.mas_bottom).offset(10);
        make.left.offset(0);
        make.width.offset(SCREEN_WIDTH);
        //make.height.offset(200).priorityHigh();
        make.height.offset(SCREEN_WIDTH);
    }];
    
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.goods_pic.mas_bottom).offset(10);
        make.width.offset(SCREEN_WIDTH-20);
        make.left.offset(10);
    }];
    
    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.title.mas_bottom).offset(10);
        make.left.offset(10);
    }];
    
    [self.number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.title.mas_bottom).offset(10);
        make.right.offset(-10);
    }];
    
    [self.intro mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.price.mas_bottom).offset(20);
        make.left.offset(10);
        make.width.offset(SCREEN_WIDTH-20);
    }];
    

}
-(void)setModel:(SupplyAndDemandDetailsModel *)model{
    _model=model;
    self.name.text=self.model.member_id;
    self.time.text=self.model.register_date;
    [self.head sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGURL,self.model.member_image]] placeholderImage:[UIImage imageNamed:@"图片空白页"]];
    self.title.text=self.model.goods_name;
    self.price.text=[NSString stringWithFormat:@"₱:%@",self.model.price];
    self.number.text=[NSString stringWithFormat:@"residue:  %@  piece",self.model.num];
    [self.goods_pic sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGURL,self.model.member_image]] placeholderImage:[UIImage imageNamed:@"图片空白页"]];
    self.intro.text=[NSString stringWithFormat:@"intro:%@",self.model.intro];
}
@end
